@page "/pdf/image-insertion"
@inject Microsoft.JSInterop.IJSRuntime JS
@using System.IO
@using Syncfusion.Blazor.Buttons
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnvironment
@inherits SampleBaseComponent;
@*Hidden:Lines*@

@using BlazorDemos.Data.FileFormats.PDF

@*End:Hidden*@

<SampleDescription>
   <p>This sample demonstrates how to insert various raster and vector images (JPEG, PNG, TIFF, EMF, and GIF) in the PDF document. This sample also demonstrates the image masking capability in the Essential PDF library.</p> 
</SampleDescription>
<ActionDescription>
   <p>It is also possible to rotate and paginate the images in the PDF document. More information about the images can be found in this documentation <a target='_blank'
href='https://help.syncfusion.com/file-formats/pdf/working-with-images?_ga=2.150744822.1703522802.1584005056-1302582622.1556169414'> section.</a></p>
</ActionDescription>

<div class="control-section">
    <p style="font-weight:normal">Click the button to view a PDF document generated by Essential PDF. Please note that Adobe Reader or its equivalent is required to view the resultant document. </p>

    <div class="button-section">
        <div id="button-control">
            <div class="row">
                <div>
                    <SfButton @onclick="ImageInsertionPDF">Generate PDF</SfButton>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .radio-control {
        margin: 0 0 5% 0;
    }

    .control-section .row {
        margin: 10px 0;
    }
</style>

@code {
    
    /// <summary>
    /// Create and download the simple PDF document
    ///<summary>
    protected async void ImageInsertionPDF(MouseEventArgs args)
    {	   
        ImageInsertionService service = new ImageInsertionService(hostingEnvironment);
        MemoryStream documentStream = service.ImageInsertionPDF();
        await JS.SaveAs("ImageInsertion.pdf", documentStream.ToArray());
    }
}
